mongodb = require './mongodb'
{Schema} = mongodb.mongoose

TickSchema =new Schema
  time:
    type:Date
    default:Date.now
  device:String
  value:Number
  lat:Number
  lng:Number

#
Tick=mongodb.mongoose.model 'Tick',TickSchema
#class TickDao
#  Tick:mongodb.mongoose.model 'Tick',new TickSchema
#  add:(data,cb) ->
#    tick = new @Tick(data)
#    console.log data.device
#    tick.save (e)->
#      if e
#        cb(e)
#      else
#        cb(null)
#
#  delete:(id,cb)->
#    @Tick.findOne
#      _id:id,
#      (err,doc)->
#        if err
#          cb err
#        else
#          doc.remove()
#          cb(null)
#
#  list:(cb)->
#    @Tick.find (err,doc)->
#      return doc unless err
#      err

module.exports = Tick









#var mongodb = require('./mongodb');
#var Schema = mongodb.mongoose.Schema;
#var TickSchema = new Schema({
#//	name:String,
#time:{type:Date,default:Date.now},
#device:String,
#value:Number,
#lat:Number,
#lng:Number
#});
#
#var Tick = mongodb.mongoose.model("Tick",TickSchema);
#//var TickDAO=function () {};
#module.exports.add= function (name,device,callback) {
#var newTick = new Tick();
#newTick.name=name;
#newTick.device=device;
#newTick.save(function(err){
#  if(err){
#  callback(err);
#}else{
#callback(null);
#}
#});
#};
#//
#//module.exports.list= function (callback) {
#//	var newTick = new Tick();
#//	newTick.name=name;
#//	newTick.device=device;
#//	newTick.save(function(err){
#//		if(err){
#//			callback(err);
#//		}else{
#//			callback(null);
#//		}
#//	});
#//};